//
//  DKReachable.m
//  xiaoquan
//
//  Created by 许建勇 on 15/9/29.
//  Copyright © 2015年 Alex. All rights reserved.
//

#import "DKReachable.h"

@implementation DKReachable

+ (Reachability *)shareReachble
{
    static dispatch_once_t once;
    static Reachability *reach;
    dispatch_once(&once, ^ {
        reach = [Reachability reachabilityForInternetConnection];
        [reach setReachableBlock:^(Reachability * reachability)
         {
             dispatch_async(dispatch_get_main_queue(),
                            ^{
                                [[NSNotificationCenter defaultCenter] postNotificationName:kReachableNotificationReachable object:nil];
                            });
         }];
        [reach setUnreachableBlock:^(Reachability * reachability)
         {
             dispatch_async(dispatch_get_main_queue(),
                            ^{
                                [[NSNotificationCenter defaultCenter] postNotificationName:kReachableNotificationUnreachable object:nil];
                            });
         }];
        [reach startNotifier];
    });
    return reach;
}


@end
